Arguments? Path filing wrong? [on hold]
Posted
by
user3034947
on Programmers
See other posts from Programmers
or by user3034947
Published on 2014-06-05T12:01:00Z
Indexed on
2014/06/05
15:36 UTC
Read the original article
Hit count: 145
I'm working through the Java SE 7 programming activity and I'm having trouble sort of understanding how arguments work.
Here's the code:
public class CopyFileTree implements FileVisitor<Path> {
private Path source;
private Path target;
public CopyFileTree(Path source, Path target) {
this.source = source;
this.target = target;
}
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
// Your code goes here
Path newdir = target.resolve(source.relativize(dir));
try {
Files.copy(dir, newdir);
} catch (FileAlreadyExistsException x) {
// ignore
} catch (IOException x) {
System.err.format("Unable to create: %s: %s%n",
newdir, x);
return SKIP_SUBTREE;
}
return CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs
) {
// Your code goes here
Path newdir = target.resolve(source.relativize(file));
try {
Files.copy(file, newdir, REPLACE_EXISTING);
} catch (IOException x) {
System.err.format("Unable to copy: %s: %s%n", source, x);
}
return CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc
) {
return CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc
) {
if (exc instanceof FileSystemLoopException) {
System.err.println("cycle detected: " + file);
} else {
System.err.format("Unable to copy: %s: %s%n", file, exc);
}
return CONTINUE;
}
}
It says to test this I need to enter arguments in properties of the project which I did? Can someone clarity what I'm doing wrong?
© Programmers or respective owner